<template>
    <div>
        <h1>登录</h1>
        <table class="table">
            <tbody>
                <tr>
                    <td>用户名:</td>
                    <td>
                        <input type="text" v-model="data.userName">
                    </td>
                </tr>
                <tr>
                    <td>密码:</td>
                    <td>
                        <input type="password" v-model="data.userPwd">
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="button" value="登录" @click="Login">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref} from 'vue';
import axios from 'axios';
const data=ref({
    "houseId": 0,
    "userName": "",
    "userPwd": "",
    "houseHao": "",
    "houseName": "",
    "housePoen": "",
    "houseSex": ""
})
const Login=()=>{
    axios.get("https://localhost:7187/api/HouseNum/Login",{params:data.value}).then(res=>{
        if(res.data.houseId==-1)
    {
        alert("用户名错误！")
        return;
    }
    if(res.data.houseId==-2)
    {
        alert("密码错误！")
        return;
    }
    if(res.data.houseId>0)
    {
        alert("登录成功！");
        location.href="Show";
    }
    })
}
</script>

<style scoped>

</style>